import xml2js from 'xml2js';

function WipAttLoader(str) {
    let jsonRes;
    let jsonData = {};
    if (str == null || str === '') {
        return jsonData;
    }
    if (str !== null || str !== '') {
        xml2js.parseString(str, {explicitArray: false, ignoreAttrs: true}, function (err, result) {
            let jsonStr = JSON.stringify(result);
            let jsonObj = JSON.parse(jsonStr);
            jsonRes = jsonObj;
        });
    }
    //解析jsonRes
    const type = jsonRes.Data.Speciality;
    switch (type) {
    case 'HULL':
        jsonData = SpdHullAttLoader(jsonRes);
        break;
    case 'PIPE':
        jsonData = SpdPipeAttLoader(jsonRes);
        break;
    default:
        break;
    }
    return jsonData;
}

function SpdHullAttLoader(jsonRes) {
    let jsonData = {};
    //1.添加baseInfo
    let baseInfo = {};
    //添加head信息
    if ((jsonRes.Data.MetaData.Type !== null || jsonRes.Data.MetaData.Type !== '') && jsonRes.Data.MetaData.Type === 'AssemblyPartDraw') {
        baseInfo['attributeType'] = 'SPD-ASS-M01';
        baseInfo['attributeName'] = '结构小组立信息';
    }
    //添加表格高度与跨度
    baseInfo['line'] = '6';
    baseInfo['colSpan'] = '4';
    //定义tableInfo信息
    let modelArray = [];
    let tableInfo = [];
    if (jsonRes.Data.MetaData.ProjectNumber !== null || jsonRes.Data.MetaData.ProjectNumber !== '') {
        tableInfo.push({
            'key': '工程编号',
            'value': jsonRes.Data.MetaData.ProjectNumber,
        });
    }
    if (jsonRes.Data.MetaData.Block !== null || jsonRes.Data.MetaData.Block !== '') {
        tableInfo.push({
            'key': '分段名',
            'value': jsonRes.Data.MetaData.Block,
        });
    }
    if (jsonRes.Data.AssemblyProp.Name !== null || jsonRes.Data.AssemblyProp.Name !== '') {
        tableInfo.push({
            'key': '部件名',
            'value': jsonRes.Data.AssemblyProp.Name,
        });
    }
    if (JSON.stringify(jsonRes.Data.AssemblyProp.Weight)) {
        tableInfo.push({
            'key': '部件重量',
            'value': jsonRes.Data.AssemblyProp.Weight.Value + jsonRes.Data.AssemblyProp.Weight.Unit,
        });
    }
    if (JSON.stringify(jsonRes.Data.AssemblyProp.Quantity)) {
        tableInfo.push({
            'key': '部件数量',
            'value': jsonRes.Data.AssemblyProp.Quantity.Value + jsonRes.Data.AssemblyProp.Quantity.Unit,
        });
    }
    if (jsonRes.Data.AssemblyProp.Location !== null || jsonRes.Data.AssemblyProp.Location !== '') {
        tableInfo.push({
            'key': '部件位置',
            'value': jsonRes.Data.AssemblyProp.Location,
        });
    }
    if (JSON.stringify(jsonRes.Data.AssemblyProp.WeldingInfo.WeldingTotalLength)) {
        tableInfo.push({
            'key': '焊接总长',
            'value': jsonRes.Data.AssemblyProp.WeldingInfo.WeldingTotalLength.Value + jsonRes.Data.AssemblyProp.WeldingInfo.WeldingTotalLength.Unit,
        });
    }

    if (jsonRes.Data.AssemblyProp.WorkingLocation !== null || jsonRes.Data.AssemblyProp.WorkingLocation !== '') {
        tableInfo.push({
            'key': '制作场地',
            'value': jsonRes.Data.AssemblyProp.WorkingLocation,
        });
    }
    if (jsonRes.Data.AssemblyProp.Destination !== null || jsonRes.Data.AssemblyProp.Destination !== '') {
        tableInfo.push({
            'key': '下级流向',
            'value': jsonRes.Data.AssemblyProp.Destination,
        });
    }
    //模型信息放入tableBaseInfo的tableInfo节点
    baseInfo['tableInfo'] = tableInfo;
    //将tableBaseInfo放入jsonData的tableBaseInfo节点
    jsonData['baseInfo'] = baseInfo;

    //2.添加tabInfo(标签页信息)
    let tabInfo = [];
    //定义tableInfoObj
    //let tabInfoObj = {};

    if (jsonRes.Data.HullModelProp.ModelPart) {
        let length;
        if (!Array.isArray(jsonRes.Data.HullModelProp.ModelPart)) {
            length = 1;
        } else {
            length = jsonRes.Data.HullModelProp.ModelPart.length;
        }
        for (let i = 0; i < length; i++) {
            //将所有HullModelProp节点下的模型加入modelArray数组
            if (Array.isArray(jsonRes.Data.HullModelProp.ModelPart)) {
                modelArray.push(jsonRes.Data.HullModelProp.ModelPart[i]);
            }
            if (!Array.isArray(jsonRes.Data.HullModelProp.ModelPart)) {
                modelArray.push(jsonRes.Data.HullModelProp.ModelPart);
            }
        }
    }
    //定义tabName
    if ((jsonRes.Data.MetaData.Type !== null || jsonRes.Data.MetaData.Type !== '') && jsonRes.Data.MetaData.Type === 'AssemblyPartDraw') {
        const tabName = ['材料清单', '焊缝信息'];
        let materialInfoArr = [];
        for (let i = 0; i < tabName.length; i++) {
            let tabInfoObj = {};
            tabInfoObj['tabName'] = tabName[i];
            tabInfoObj['tableData'] = [];
            let tableObj = {};
            tableObj['line'] = '5';
            tableObj['column'] = '5';
            let headObj = [];
            if (tabInfoObj['tabName'] === '材料清单') {
                headObj = [
                    {
                        'key': 'number',
                        'name': '件号',
                    },
                    {
                        'key': 'name',
                        'name': '零件名',
                    },
                    {
                        'key': 'stand',
                        'name': '规格',
                    },
                    {
                        'key': 'quantity',
                        'name': '数量',
                    },
                    {
                        'key': 'weight',
                        'name': '重量',
                    },
                ];
                tableObj['head'] = headObj;
                if (modelArray) {
                    for (let j = 0; j < modelArray.length; j++) {
                        const materialObj = {};
                        const attribute = [];
                        //得到所有的模型的材料信息(如果存在)
                        //得到所有的模型零件名
                        if (modelArray[j].ModelName !== null || modelArray[j].ModelName !== '') {
                            materialObj['modelName'] = modelArray[j].ModelName;
                        }

                        if (JSON.stringify(modelArray[j].Number)) {
                            attribute.push(modelArray[j].Number);
                        }
                        if (JSON.stringify(modelArray[j].ModelName)) {
                            attribute.push(modelArray[j].ModelName);
                        }
                        if ((modelArray[j].Type !== null || modelArray[j].Type !== '') && modelArray[j].Type !== '1') {
                            if (JSON.stringify(modelArray[j].Thickness)) {
                                attribute.push(modelArray[j].Thickness.Value + modelArray[j].Thickness.Unit + ' ' + modelArray[j].MaterialInfo.Quality);
                            }
                        } else {
                            if (JSON.stringify(modelArray[j].MaterialInfo)) {
                                attribute.push(modelArray[j].MaterialInfo.MaterialSpecification + ' ' + modelArray[j].MaterialInfo.Quality);
                            }
                        }
                        if (JSON.stringify(modelArray[j].Quantity)) {
                            attribute.push(modelArray[j].Quantity.Value + ' ' + modelArray[j].Quantity.Unit);
                        }
                        if (JSON.stringify(modelArray[j].Weight)) {
                            attribute.push(modelArray[j].Weight.Value + ' ' + modelArray[j].Weight.Unit);
                        }
                        materialObj['attribute'] = attribute;
                        materialInfoArr.push(materialObj);
                    }
                }
                tableObj['row'] = materialInfoArr;
                tabInfoObj['tableData'][0] = tableObj;
                tabInfo.push(tabInfoObj);
            }
            else if (tabInfoObj['tabName'] === '焊缝信息') {
                for (let n = 0; n < 2; n++) {
                    tableObj = {};
                    tableObj['line'] = '5';
                    tableObj['column'] = '5';

                    let headObj1 = [
                        {
                            'key': 'weldingParts',
                            'name': '焊接零件',
                        },
                        {
                            'key': 'weldType',
                            'name': '焊接类型',
                        },
                        {
                            'key': 'weldPosition',
                            'name': '焊接方式',
                        },
                        {
                            'key': 'weldMethod',
                            'name': '焊接方法',
                        },
                        {
                            'key': 'layers',
                            'name': '焊接层数',
                        },
                    ];
                    let headObj2 = [
                        {
                            'key': 'weldLength',
                            'name': '焊接长度',
                        },
                        {
                            'key': 'connAngle',
                            'name': '链接角度',
                        },
                        {
                            'key': 'bevel1',
                            'name': '坡口1',
                        },
                        {
                            'key': 'bevel2',
                            'name': '坡口2',
                        },
                    ];
                    n === 0 ? tableObj['head'] = headObj1 : tableObj['head'] = headObj2;
                    const weldingInfoArrTemp = [];
                    const weldingInfoArr = [];
                    if (jsonRes.Data.AssemblyProp.WeldingInfo.WeldPart) {
                        const weldPartArr = [];
                        if (!Array.isArray(jsonRes.Data.AssemblyProp.WeldingInfo.WeldPart)) {
                            weldPartArr.push(jsonRes.Data.AssemblyProp.WeldingInfo.WeldPart);
                        } else {
                            for (let k = 0; k < jsonRes.Data.AssemblyProp.WeldingInfo.WeldPart.length; k++) {
                                weldPartArr.push(jsonRes.Data.AssemblyProp.WeldingInfo.WeldPart[k]);
                            }
                        }
                        for (let o = 0; o < weldPartArr.length; o++) {
                            const weldingObj = {};
                            const attribute = [];
                            weldingInfoArrTemp.push(weldPartArr[o]);
                            if (JSON.stringify(weldingInfoArrTemp)) {
                                if (n === 0) {
                                    if (weldingInfoArrTemp[o].Part1 !== '' && weldingInfoArrTemp[o].Part2 !== '') {
                                        attribute.push(weldingInfoArrTemp[o].Part1 + '-' + weldingInfoArrTemp[o].Part2);
                                    }
                                    if (weldingInfoArrTemp[o].WeldType !== '') {
                                        attribute.push(weldingInfoArrTemp[o].WeldType);
                                    }
                                    if (weldingInfoArrTemp[o].WeldPosition !== '') {
                                        attribute.push(weldingInfoArrTemp[o].WeldPosition);
                                    }
                                    if (weldingInfoArrTemp[o].WeldPosition !== '') {
                                        attribute.push(weldingInfoArrTemp[o].WeldPosition);
                                    }
                                    if (JSON.stringify(weldingInfoArrTemp[o].Layers !== '')) {
                                        attribute.push(weldingInfoArrTemp[o].Layers.Value + weldingInfoArrTemp[o].Layers.Unit);
                                    }
                                    weldingObj['attribute'] = attribute;
                                    weldingInfoArr.push(weldingObj);
                                } else {
                                    if (JSON.stringify(weldingInfoArrTemp[o].WeldLength)) {
                                        attribute.push(weldingInfoArrTemp[o].WeldLength.Value + weldingInfoArrTemp[o].WeldLength.Unit);
                                    }
                                    if (weldingInfoArrTemp[o].ConnAngle !== '') {
                                        attribute.push(weldingInfoArrTemp[o].ConnAngle);
                                    }
                                    if (weldingInfoArrTemp[o].Bevel1 !== '') {
                                        attribute.push(weldingInfoArrTemp[o].Bevel1);
                                    }
                                    if (weldingInfoArrTemp[o].Bevel2 !== '') {
                                        attribute.push(weldingInfoArrTemp[o].Bevel2);
                                    }

                                    weldingObj['attribute'] = attribute;
                                    weldingInfoArr.push(weldingObj);
                                }
                            }
                        }
                        tableObj['row'] = weldingInfoArr;
                        tabInfoObj['tableData'][n] = tableObj;
                    }
                }
                tabInfo.push(tabInfoObj);
            }

        }
        //将tabInfo放入jsonData的tabInfo节点
        jsonData['tabInfo'] = tabInfo;
    }
    return jsonData
}

function SpdPipeAttLoader(jsonRes) {
    let jsonData = {};
    //1.添加tableBaseInfo
    let baseInfo = {};
    //添加head信息
    if ((jsonRes.Data.MetaData.Type !== null || jsonRes.Data.MetaData.Type !== '') && jsonRes.Data.MetaData.Type === 'PipeSpoolDraw') {
        baseInfo['attributeType'] = 'SPD-SP-M01';
        baseInfo['attributeName'] = '管子制作信息';
    }
    //添加表格高度与跨度
    baseInfo['line'] = '6';
    baseInfo['colSpan'] = '4';
    //定义tableInfo信息
    let modelArray = [];
    let tableInfo = [];
    if (jsonRes.Data.MetaData.ProjectNumber !== null || jsonRes.Data.MetaData.ProjectNumber !== '') {
        tableInfo.push({
            'key': '工程编号',
            'value': jsonRes.Data.MetaData.ProjectNumber,
        });
    }
    if (jsonRes.Data.SpoolProp.PalletIdentification !== null || jsonRes.Data.SpoolProp.PalletIdentification !== '') {
        tableInfo.push({
            'key': '托盘编号',
            'value': jsonRes.Data.SpoolProp.PalletIdentification,
        });
    }
    if (jsonRes.Data.SpoolProp.Identification !== null || jsonRes.Data.SpoolProp.Identification !== '') {
        tableInfo.push({
            'key': '管子件号',
            'value': jsonRes.Data.SpoolProp.Identification,
        });
    }
    if (jsonRes.Data.SpoolProp.ZoneCode !== null || jsonRes.Data.SpoolProp.ZoneCode !== '') {
        tableInfo.push({
            'key': '区域',
            'value': jsonRes.Data.SpoolProp.ZoneCode,
        });
    }
    if (jsonRes.Data.SpoolModelProp.ModelPart) {
        let length;
        if (!Array.isArray(jsonRes.Data.SpoolModelProp.ModelPart)) {
            length = 1;
        } else {
            length = jsonRes.Data.SpoolModelProp.ModelPart.length;
        }
        for (let i = 0; i < length; i++) {
            //将所有SpoolModelProp节点下的模型加入modelArray数组
            if (Array.isArray(jsonRes.Data.SpoolModelProp.ModelPart)) {
                modelArray.push(jsonRes.Data.SpoolModelProp.ModelPart[i]);
            }
            if (!Array.isArray(jsonRes.Data.SpoolModelProp.ModelPart)) {
                modelArray.push(jsonRes.Data.SpoolModelProp.ModelPart);
            }
            if (modelArray[i].Type !== null || modelArray[i].Type !== '') {
                if (modelArray[i].Type === '0' && modelArray[i].MainPipe === '1') {
                    if (JSON.stringify(modelArray[i].Diameter)) {
                        tableInfo.push({
                            'key': '通径',
                            'value': modelArray[i].Diameter.Value + modelArray[i].Diameter.Unit,
                        });
                    }
                    if (JSON.stringify(modelArray[i].Diameter)) {
                        tableInfo.push({
                            'key': '外径',
                            'value': modelArray[i].Diameter.Value + modelArray[i].Diameter.Unit,
                        });
                    }
                    if (JSON.stringify(modelArray[i].Thickness)) {
                        tableInfo.push({
                            'key': '壁厚',
                            'value': modelArray[i].Thickness.Value + modelArray[i].Thickness.Unit,
                        });
                    }
                    if (JSON.stringify(modelArray[i].ThicknessClass)) {
                        tableInfo.push({
                            'key': '壁厚等级',
                            'value': modelArray[i].ThicknessClass,
                        });
                    }
                    if (JSON.stringify(modelArray[i].MaterialInfo)) {
                        tableInfo.push({
                            'key': '材质',
                            'value': modelArray[i].MaterialInfo.Quality,
                        });
                    }
                }
            }
        }
    }
    if (JSON.stringify(jsonRes.Data.SpoolProp.Weight)) {
        tableInfo.push({
            'key': '重量',
            'value': jsonRes.Data.SpoolProp.Weight.Value + jsonRes.Data.SpoolProp.Weight.Unit,
        });
    }
    if (jsonRes.Data.SpoolProp.SurfTreatment !== null || jsonRes.Data.SpoolProp.SurfTreatment !== '') {
        tableInfo.push({
            'key': '处理',
            'value': jsonRes.Data.SpoolProp.SurfTreatment,
        });
    }
    if (jsonRes.Data.SpoolProp.OuterSurfacePaint !== null || jsonRes.Data.SpoolProp.OuterSurfacePaint !== '') {
        tableInfo.push({
            'key': '涂装',
            'value': jsonRes.Data.SpoolProp.OuterSurfacePaint,
        });
    }
    //模型信息放入tableBaseInfo的tableInfo节点
    baseInfo['tableInfo'] = tableInfo;
    //将tableBaseInfo放入jsonData的tableBaseInfo节点
    jsonData['baseInfo'] = baseInfo;

    //2.添加tabInfo(标签页信息)
    let tabInfo = [];
    //定义tableInfoObj
    //let tabInfoObj = {};

    //定义tabName

    if ((jsonRes.Data.MetaData.Type !== null || jsonRes.Data.MetaData.Type !== '') && jsonRes.Data.MetaData.Type === 'PipeSpoolDraw') {
        const tabName = ['材料清单', '装配信息', '弯管信息', '校管信息'];
        let materialInfoArr = [];
        for (let i = 0; i < tabName.length; i++) {
            let tabInfoObj = {};
            (tabName[i] !== '校管信息') ? tabInfoObj['tabType'] = '0' : tabInfoObj['tabType'] = '1';
            tabInfoObj['tabName'] = tabName[i];
            tabInfoObj['tableData'] = [];
            let tableObj = {};
            tableObj['line'] = '5';
            tableObj['column'] = '5';
            let headObj = [];
            if (tabInfoObj['tabName'] === '材料清单') {
                headObj=[
                    {
                        'key':'number',
                        'name':'件号',
                    },
                    {
                        'key':'stand',
                        'name':'标准',
                    },
                    {
                        'key':'desc',
                        'name':'说明',
                    },
                    {
                        'key':'length',
                        'name':'长度',
                    },
                    {
                        'key':'remark',
                        'name':'备注',
                    },
                ];
                tableObj['head'] = headObj;
                if (modelArray) {
                    for (let j = 0; j < modelArray.length; j++) {
                        const materialObj = {};
                        const attribute = [];
                        //得到所有的模型的材料信息(如果存在)
                        //得到所有的模型零件名
                        if (modelArray[j].ModelName !== null || modelArray[j].ModelName !== '') {
                            materialObj['modelName'] = modelArray[j].ModelName;
                        }
                        if (JSON.stringify(modelArray[j].MaterialInfo)) {
                            if (JSON.stringify(modelArray[j].Number)) {
                                attribute.push(modelArray[j].Number);
                            }
                            attribute.push(modelArray[j].MaterialInfo.STDPartIdentification);
                            attribute.push(modelArray[j].MaterialInfo.Name);
                            if (JSON.stringify(modelArray[j].TotalLength)) {
                                attribute.push(modelArray[j].TotalLength.Value + modelArray[j].TotalLength.Unit);
                            }
                            if (!JSON.stringify(modelArray[j].TotalLength)) {
                                attribute.push('');
                            }
                            attribute.push('');
                        }
                        materialObj['attribute'] = attribute;
                        materialInfoArr.push(materialObj);
                    }

                }
                tableObj['row'] = materialInfoArr;
                tabInfoObj['tableData'][0] = tableObj;
                tabInfo.push(tabInfoObj);
            }
            else if (tabInfoObj['tabName'] === '装配信息') {

                headObj=[
                    {
                        'key':'number',
                        'name':'件号',
                    },
                    {
                        'key':'gou',
                        'name':'夹角',
                    },
                    {
                        'key':'arg',
                        'name':'转角',
                    },
                    {
                        'key':'plane',
                        'name':'参考面',
                    },
                    {
                        'key':'remark',
                        'name':'备注',
                    },
                ];
                tableObj['head'] = headObj;
                const assemblyInfoArrTemp = [];
                const assemblyInfoArr = [];
                if (jsonRes.Data.SpoolAssembly.AssemblyPart) {
                    for (let k = 0; k < jsonRes.Data.SpoolAssembly.AssemblyPart.length; k++) {
                        const assObj = {};
                        const attribute = [];
                        assemblyInfoArrTemp.push(jsonRes.Data.SpoolAssembly.AssemblyPart[k]);
                        if (JSON.stringify(assemblyInfoArrTemp)) {
                            if (JSON.stringify(assemblyInfoArrTemp[k].Number)) {
                                attribute.push(assemblyInfoArrTemp[k].Number);
                                //info['number'] = assemblyInfoArrTemp[i].Number;
                                for (let m = 0; m < materialInfoArr.length; m++) {
                                    if (assemblyInfoArrTemp[k].Number === materialInfoArr[m].attribute[0]) {
                                        assObj['modelName'] = materialInfoArr[m].modelName;
                                    }
                                }
                            }
                            if (JSON.stringify(assemblyInfoArrTemp[k].Rotation)) {
                                attribute.push(assemblyInfoArrTemp[k].Rotation.Value + assemblyInfoArrTemp[k].Rotation.Unit);
                            }
                            if (JSON.stringify(assemblyInfoArrTemp[k].Inclination)) {
                                attribute.push(assemblyInfoArrTemp[k].Inclination.Value + assemblyInfoArrTemp[k].Inclination.Unit);
                            }
                            if (JSON.stringify(assemblyInfoArrTemp[k].RefPlane)) {
                                attribute.push(assemblyInfoArrTemp[k].RefPlane);
                            }
                            attribute.push('');
                        }
                        assObj['attribute'] = attribute;
                        assemblyInfoArr.push(assObj);
                    }
                }
                tableObj['row'] = assemblyInfoArr;
                tabInfoObj['tableData'][0] = tableObj;
                tabInfo.push(tabInfoObj);
            }
            else if (tabInfoObj['tabName'] === '弯管信息') {
                for (let n = 0; n < 2; n++) {
                    tableObj = {};
                    tableObj['line'] = '5';
                    tableObj['column'] = '5';

                    let headObj1=[
                        {
                            'key':'number',
                            'name':'件号',
                        },
                        {
                            'key':'start',
                            'name':'始端',
                        },
                        {
                            'key':'macNum',
                            'name':'机号',
                        },
                        {
                            'key':'rad',
                            'name':'弯管半径',
                        },
                        {
                            'key':'excess',
                            'name':'余量',
                        },
                    ];
                    let headObj2=[
                        {
                            'key':'len',
                            'name':'送长',
                        },
                        {
                            'key':'arg',
                            'name':'转角',
                        },
                        {
                            'key':'ben',
                            'name':'弯角',
                        },
                        {
                            'key':'gad',
                            'name':'弧长',
                        },
                        {
                            'key':'total',
                            'name':'累计',
                        },
                    ];
                    n === 0 ? tableObj['head'] = headObj1 : tableObj['head'] = headObj2;


                    const bendingInfoArrTemp = [];
                    const bendingInfoArr = [];
                    if (jsonRes.Data.SpoolBendingInfo.BendingPart) {
                        for (let o = 0; o < jsonRes.Data.SpoolBendingInfo.BendingPart.length; o++) {
                            const bendingObj = {};
                            const attribute = [];
                            bendingInfoArrTemp.push(jsonRes.Data.SpoolBendingInfo.BendingPart[o]);
                            if (JSON.stringify(bendingInfoArrTemp)) {
                                if (n === 0) {
                                    if (JSON.stringify(bendingInfoArrTemp[o].Number)) {
                                        attribute.push(bendingInfoArrTemp[o].Number);
                                        for (let p = 0; p < materialInfoArr.length; p++) {
                                            if (bendingInfoArrTemp[o].Number === materialInfoArr[p].attribute[0]) {
                                                bendingObj['modelName'] = materialInfoArr[p].modelName;
                                            }
                                        }
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].Index)) {
                                        attribute.push(bendingInfoArrTemp[o].Index);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].BendingMachine)) {
                                        attribute.push(bendingInfoArrTemp[o].BendingMachine);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].Radius)) {
                                        attribute.push(bendingInfoArrTemp[o].Radius.Value + bendingInfoArrTemp[o].Radius.Unit);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].Excess)) {
                                        attribute.push(bendingInfoArrTemp[o].Excess);
                                    }
                                    bendingObj['attribute'] = attribute;
                                    bendingInfoArr.push(bendingObj);
                                } else {
                                    if (JSON.stringify(bendingInfoArrTemp[o].Length)) {
                                        attribute.push(bendingInfoArrTemp[o].Length.Value + bendingInfoArrTemp[o].Length.Unit);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].Rotation)) {
                                        attribute.push(bendingInfoArrTemp[o].Rotation.Value + bendingInfoArrTemp[o].Rotation.Unit);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].BentAngle)) {
                                        attribute.push(bendingInfoArrTemp[o].BentAngle.Value + bendingInfoArrTemp[o].BentAngle.Unit);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].ArcLength)) {
                                        attribute.push(bendingInfoArrTemp[o].ArcLength.Value + bendingInfoArrTemp[o].ArcLength.Unit);
                                    }
                                    if (JSON.stringify(bendingInfoArrTemp[o].TotalLength)) {
                                        attribute.push(bendingInfoArrTemp[o].TotalLength.Value + bendingInfoArrTemp[o].TotalLength.Unit);
                                    }
                                    bendingObj['attribute'] = attribute;
                                    bendingInfoArr.push(bendingObj);
                                }
                            }
                        }
                        tableObj['row'] = bendingInfoArr;
                        tabInfoObj['tableData'][n] = tableObj;
                    }
                }
                tabInfo.push(tabInfoObj);
            }
            else if (tabInfoObj['tabName'] === '校管信息') {

                headObj=[
                    {
                        'key':'number',
                        'name':'点号',
                    },
                    {
                        'key':'locationX',
                        'name':'节点相对船体坐标X',
                    },
                    {
                        'key':'locationY',
                        'name':'节点相对船体坐标Y',
                    },
                    {
                        'key':'locationZ',
                        'name':'节点相对船体坐标Z',
                    },
                    {
                        'key':'conPip',
                        'name':'连接管子',
                    }
                ];
                tableObj['head'] = headObj;
                const proofreadInfoArrTemp = [];
                const proofreadInfoArr = [];
                if (JSON.stringify(jsonRes.Data.SpoolProofreadInfo.Type)) {
                    tableObj['type'] = jsonRes.Data.SpoolProofreadInfo.Type;
                }
                if (jsonRes.Data.SpoolProofreadInfo.Node) {
                    for (let i = 0; i < jsonRes.Data.SpoolProofreadInfo.Node.length; i++) {
                        const proofreadObj = {};
                        const attribute = [];
                        proofreadInfoArrTemp.push(jsonRes.Data.SpoolProofreadInfo.Node[i]);
                        if (JSON.stringify(proofreadInfoArrTemp)) {
                            if (JSON.stringify(proofreadInfoArrTemp[i].Number)) {
                                proofreadObj['number'] = proofreadInfoArrTemp[i].Number;
                                attribute.push(proofreadInfoArrTemp[i].Number);
                            }
                            if (JSON.stringify(proofreadInfoArrTemp[i].X)) {
                                attribute.push(proofreadInfoArrTemp[i].X);
                            }
                            if (JSON.stringify(proofreadInfoArrTemp[i].Y)) {
                                attribute.push(proofreadInfoArrTemp[i].Y);
                            }
                            if (JSON.stringify(proofreadInfoArrTemp[i].Z)) {
                                attribute.push(proofreadInfoArrTemp[i].Z);
                            }
                            if (JSON.stringify(proofreadInfoArrTemp[i].ConnectionSpool)) {
                                attribute.push(proofreadInfoArrTemp[i].ConnectionSpool);
                            }
                        }
                        proofreadObj['attribute'] = attribute;
                        proofreadInfoArr.push(proofreadObj);
                    }
                }
                tableObj['row'] = proofreadInfoArr;
                tabInfoObj['tableData'][0] = tableObj;
                tabInfo.push(tabInfoObj);
            }
        }
        //将tabInfo放入jsonData的tabInfo节点
        jsonData['tabInfo'] = tabInfo;
    }
    return jsonData
}

export {WipAttLoader} 